#include "app_buffer.h"
#include "log.h"

int main(int argc, char *argv[])
{
    // 1.初始化缓存
    Buffer *buffer = app_buffer_init(16);

    // 2.添加数据
    app_buffer_write(buffer, "01234567", 8);
    // 读取数据
    char read_buffer[4] = {0};
    app_buffer_read(buffer, read_buffer, 4);
    log_info("read buffer:%.*s", 4, read_buffer);
    // 读取数据
    char read_buffer2[4] = {0};
    app_buffer_read(buffer, read_buffer2, 4);
    log_info("read buffer:%.*s", 4, read_buffer2);

    // 添加数据
    app_buffer_write(buffer, "89abcdef", 9);
    // 读取数据(读取无数据)
    char read_buffer3[10] = {0};
    app_buffer_read(buffer, read_buffer3, 7);
    log_info("read buffer:%.*s", 10, read_buffer3);

    // 读取数据
    char read_buffer4[7] = {0};
    app_buffer_read(buffer, read_buffer4, 4);
    log_info("read buffer:%.*s", 7, read_buffer4);

    // 添加数据(写入失败)
   app_buffer_write(buffer, "11111111111111", 9);
   
    return 0;
}